/*
 * Process.h
 *
 *  Created on: Mar 9, 2012
 *      Author: Kyle Richardson
 *              Jay Fernandez
 */

#ifndef PROCESS_H_
#define PROCESS_H_
#include "arraylist.h"
enum state {
    RUNNING,
    READY,
    INTERRUPTED,
    BLOCKED
};

enum interrupt {
    CALC,
    PRODUCER,
    CONSUMER,
    UI
};

typedef struct request_str {
    int step;                   //instruction location of the request
    enum interrupt interrupt;   //syscall
} RequestStr;

typedef struct process_str {
    enum interrupt type;    //type of process
	int	num_steps;          //number of instructions
	int num_requests;       //number of requests
	RequestStr ** requests;	//an array of requests
	int priority;
	array_list tickets;
} ProcessStr;

typedef struct pcb_str {
	int	pid;                //id
	int next_step;          //location where process stopped + 1
	enum state state;       //state of the process
	int waiting_on;         //which queue is it in if it is waiting on something (blocked)
	int owns;               //which semaphore does it own
    ProcessStr *process;    //Process association with PCB
} PCBStr;

ProcessStr* createProcess(enum interrupt);

PCBStr* createPCB();

RequestStr* createRequest(ProcessStr *process);

#endif /* PROCESS_H_ */
